<?php

/**
 * Subclass for performing query and update operations on the 'hc_concert' table.
 *
 * 
 *
 * @package lib.model
 */ 
class ConcertPeer extends BaseConcertPeer
{
  /**
   * retourne les prochains concerts
   * 
   * @param integer limite
   * @param booelan clause groupby
   * @return array of objects concert
   */
  public static function getUpcomingShows($limit = null, $group_by_tour = false, $sort = 'ASC')
  {
    $c = new Criteria();
    $c->add(ConcertPeer::PLAY_AT, date('Y-m-d H:i:s'), Criteria::GREATER_EQUAL);
    
    if ($limit)
    {
      $c->setLimit($limit);
    }
    
    if ($group_by_tour)
    {
      $c->addJoin(ConcertPeer::TOUR_ID, TourPeer::ID);
      $c->addGroupByColumn(ConcertPeer::TOUR_ID);
    }
    
    if ($sort == 'ASC')
    {
      $c->addAscendingOrderByColumn(ConcertPeer::PLAY_AT);
    }
    else 
    {
      $c->addDescendingOrderByColumn(ConcertPeer::PLAY_AT);
    }
    
    return self::doSelect($c);
  }
}
